﻿<Window x:Class="ProductKeysWin.ViewKey"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="ViewKey" SizeToContent="WidthAndHeight" WindowStartupLocation="CenterOwner">
  <Window.Resources>
    <Style x:Key="{x:Type ListBoxItem}" TargetType="{x:Type ListBoxItem}">
      <Setter Property="OverridesDefaultStyle" Value="true" />
      <Setter Property="Background" Value="Transparent" />
      <Setter Property="BorderBrush" Value="Transparent" />
      <Setter Property="BorderThickness" Value="1" />
      <Setter Property="HorizontalContentAlignment" Value="Left" />
      <Setter Property="VerticalContentAlignment" Value="Center" />
      <Setter Property="Padding" Value="3" />
      <Setter Property="Template">
        <Setter.Value>
          <ControlTemplate TargetType="{x:Type ListBoxItem}">
            <Border
              Background="{TemplateBinding Background}" 
              BorderBrush="{TemplateBinding BorderBrush}" 
              BorderThickness="{TemplateBinding BorderThickness}" 
              Padding="{TemplateBinding Padding}">
              <ContentPresenter x:Name="ContentSite" 
                HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" 
                VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
            </Border>
            <ControlTemplate.Triggers>
              <Trigger Property="IsSelected" Value="true">
                <Setter Property="Background">
                  <Setter.Value>
                    <LinearGradientBrush StartPoint="0,0" EndPoint="1,0">
                      <LinearGradientBrush.GradientStops>
                        <GradientStop Offset="0" Color="#F9F9F9"/>
                        <GradientStop Offset="1" Color="#E9E9E9"/>
                      </LinearGradientBrush.GradientStops>
                    </LinearGradientBrush>
                  </Setter.Value>
                </Setter>
                <Setter Property="BorderBrush" Value="Silver" />
                <Setter Property="Foreground" Value="Black"/>
              </Trigger>
              <MultiTrigger>
                <MultiTrigger.Conditions>
                  <Condition Property="IsSelected" Value="true" />
                  <Condition Property="Selector.IsSelectionActive" 
                             Value="false" />
                </MultiTrigger.Conditions>
                <Setter Property="Background" Value="#F8F8F8" />
                <Setter Property="BorderBrush" Value="#E0E0E0" />
              </MultiTrigger>
            </ControlTemplate.Triggers>
          </ControlTemplate>
        </Setter.Value>
      </Setter>
      <Style.Triggers>
        <Trigger Property="IsEnabled" Value="false">
          <Setter Property="Foreground" Value="Gray" />
        </Trigger>
      </Style.Triggers>
    </Style>
  </Window.Resources>
    <DockPanel>
		<StackPanel DockPanel.Dock="Top" Orientation="Horizontal">
		<StackPanel.Background>
        <LinearGradientBrush StartPoint="0,0.5" EndPoint="1,0.5">
          <LinearGradientBrush.RelativeTransform>
            <TransformGroup>
              <TranslateTransform X="-0.5" Y="-0.5"/>
              <ScaleTransform ScaleX="1" ScaleY="1"/>
              <SkewTransform AngleX="0" AngleY="0"/>
              <RotateTransform Angle="90.0172795589426"/>
              <TranslateTransform X="0.5" Y="0.5"/>
              <TranslateTransform X="-0.0015136743804197244" Y="-0.19736842105263153"/>
            </TransformGroup>
          </LinearGradientBrush.RelativeTransform>
          <LinearGradientBrush.GradientStops>
			<GradientStop Color="Black" Offset="0.0"/>
            <GradientStop Color="#565656" Offset="1"/>
          </LinearGradientBrush.GradientStops>
        </LinearGradientBrush>
		</StackPanel.Background>
			<StackPanel>
				<Label FontWeight="SemiBold" Foreground="White">Product Name:</Label>
				<Label Content="{Binding Path=Name}" Foreground="White"/>
			</StackPanel>
			<StackPanel>
				<Label FontWeight="SemiBold" Foreground="White" Visibility="Hidden">Date Claimed:</Label>
				<Label Content="{Binding Path=DateClaimed}" Foreground="White"/>
			</StackPanel>
		</StackPanel>
		<ListBox Name="lstProdKeys" MinWidth="400" MinHeight="200" ItemsSource="{Binding Path=Keys}" IsSynchronizedWithCurrentItem="True">
			<ListBox.ItemTemplate>
				<DataTemplate>
					<StackPanel Orientation="Horizontal">
						<Label FontWeight="SemiBold" Content="Key: "/>
						<Label FontWeight="Normal" Content="{Binding Path=KeyCode}"/>
						<Label FontWeight="SemiBold" Content="Allocated To: "/>
						<Label FontWeight="Normal" Content="{Binding Path=AllocatedTo}"/>
					</StackPanel>
				</DataTemplate>
			</ListBox.ItemTemplate>
		</ListBox>
    </DockPanel>
</Window>
